﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DataAccessLogic;
using System.Data;

namespace BusinessLogic
{
    [Serializable]
    public class EmailType : CodeTable<EmailType>
    {
        #region Methods
        public override void Create()
        {
            EmailTypeDataAccess.Create(this);
        }

        public override void Delete()
        {
            EmailTypeDataAccess.Delete(this);
        }

        protected override List<EmailType> ProtectedGetAll()
        {
            DataTable dt = EmailTypeDataAccess.GetAll();
            List<EmailType> codeTables = null;

            if ((dt != null) && (0 < dt.Rows.Count))
            {
                codeTables = new List<EmailType>();

                foreach (DataRow row in dt.Rows)
                {
                    codeTables.Add(EmailTypeDataAccess.BindDataToEmailType(row));
                }
            }

            return codeTables;
        }

        protected override EmailType ProtectedGetByID(Guid id)
        {
            DataRow row = EmailTypeDataAccess.GetByID(id);

            if (row != null)
            {
                return EmailTypeDataAccess.BindDataToEmailType(row);
            }

            return null;
        }
        
        public override void Update()
        {
            EmailTypeDataAccess.Update(this);
        }
        #endregion
        
        #region Properties
        public override string CacheKeyName
        {
            get
            {
                return SEPDefaults.CacheKeyNames.EMAILTYPES;
            }
        }
        #endregion
    }
}